{extend name="common:base" /}
{block name="content"}
<div class="row">
<table class="table table-striped table-bordered">
<thead>
    <tr>
        <th>备份名称</th>
        <th class="hidden-sm hidden-xs">卷数</th>
        <th class="hidden-sm hidden-xs">压缩</th>
        <th>数据大小</th>
        <th>备份时间</th>
        <th>状态</th>
        <th>操作</th>
    </tr>
</thead>
<tbody>
    {volist name="list" id="data"}
        <tr>
            <td>{$data.time|date='Ymd-His'}</td>
            <td class="hidden-sm hidden-xs">{$data.part}</td>
            <td class="hidden-sm hidden-xs">{$data.compress}</td>
            <td>{$data.size|format_bytes}</td>
            <td>{$key}</td>
            <td>-</td>
            <td class="action">
                <a class="db-import" href="{:url('recovery',['act'=>'import','time'=>$data['time']])}">还原</a>&nbsp;
                <a class="ajax-get confirm" href="{:url('recovery',['act'=>'del','time'=>$data['time']])}">删除</a>
            </td>
        </tr>
    {/volist}
</tbody>
</table>
                            </div>
<div class="row">
<a class="btn btn-info" href="{:url('backup')}">数据备份</a>
</div>
{/block}
{block name="javascript"}
<script type="text/javascript">
$(function(){
   $(".db-import").click(function(){
        var self = this, code = ".";
        $.get(self.href, success, "json");
        window.onbeforeunload = function(){ return "正在还原数据库，请不要关闭！" }
        return false;

        function success(data){
            if(data.code){
                if(data.gz){
                    data.msg += code;
                    if(code.length === 5){
                        code = ".";
                    } else {
                        code += ".";
                    }
                }
                $(self).parent().prev().text(data.msg);
                if(data.data.part){
                    $.get(self.href,
                        {"part" : data.data.part, "start" : data.data.start},
                        success,
                        "json"
                    );
                }  else {
                    window.onbeforeunload = function(){ return null; }
                }
            } else {
                alert(data.msg);
            }
        }
    });
})
</script>
{/block}
